home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / Mops 2.7 / Mops source / System source / Objinit < prev    next >
Text File  |  1995-07-16  |  3KB  |  100 lines

  1. \ Initialization of system objects.
  2.  
  3. : -MODELESS    \ Sets normal event handling - no modeless dialogs
  4.     cfas{    null-evt    mouse-evt    null-evt    key-evt
  5.             null-evt    key-evt        upd-evt        disk-evt
  6.             actv-evt    null-evt    null-evt    null-evt
  7.             null-evt    null-evt    null-evt    OS-evt
  8.             null-evt    null-evt    null-evt    null-evt
  9.             null-evt    null-evt    null-evt    HL-evt   }
  10.     put: fEvent  ;
  11.  
  12. ' null-evt fill: fevent        \ using -modeless during compilation causes
  13.                             \ strange scrolling effects in fWind
  14.  
  15.  
  16.  
  17. \ APPINIT is the startup word that we execute via ObjInit in installed
  18. \ applications.  If fWind is being used it initializes it too.  Note
  19. \ that for the Mops development environment we can't set up fWind here,
  20. \ since under System 7 fWind doesn't exist until a dictionary
  21. \ is read in, which is later than ObjInit time.  But for an installed
  22. \ application which uses fWind, fWind will be available from the start,
  23. \ so AppInit does the setting up.
  24.  
  25. : APPINIT  {  \ top left bot rt --  }
  26.     filinit
  27.     fWind? IF  lock: windowMod
  28.         ScreenBits  -> bot  -> rt  -> top  -> left
  29.         70 70 rt bot  true  setGrow: fWind
  30.         setContRect: fWind
  31.     THEN   ;
  32.  
  33.  
  34. \ SYSINIT is the startup word that initializes the nucleus objects for
  35. \ the Mops development environment above Files.
  36.  
  37. : SYSINIT
  38.     filinit
  39.     fWind  ['] window  set_class  lock: windowmod
  40.     0 -> actW
  41.     ['] (key!)  -> key!
  42.     $ F5EF  setMask: fEvent        \ mask out key up
  43.     -modeless   key!  +curs
  44.     extra_inits  ;                \ A vector for any extra initialization
  45.  
  46.  
  47. \ PAUSE should be called at strategic intervals in all applications,
  48. \ unless Key is being called frequently (see note 1 below).  Pause
  49. \ normally calls  next: fEvent  which allows a task switch to be done
  50. \ under MultiFinder, and which also handles any pending events for this
  51. \ task, such as window updates.  Remember to disable any menus etc. that
  52. \ you don't want to execute in this situation!  Unexpected re-entrancy
  53. \ is a good way to bomb!
  54.  
  55. \ NOTE THE FOLLOWING POINTS:
  56.  
  57. \ 1.  KEY also calls  next: fEvent.  So if we're waiting on keys,
  58. \ we shouldn't call Pause, especially as Pause will gobble any keys
  59. \ typed!
  60.  
  61. \ 2.  next: fEvent  calls WaitNextEvent.  If we don't want to be
  62. \ suspended until the next event for us, we need to set SleepTicks to
  63. \ a suitably low number.  PAUSE by default sets SleepTicks to zero
  64. \ temporarily.  Change this if necessary.
  65.  
  66. \ 3.  If multitasking is installed, PAUSE may be redirected (but not
  67. \ necessarily) so that it just calls NEXT_TASK to do a task switch.
  68. \ This will happen if we have a foreground task calling  next: fEvent
  69. \ repeatedly, while we do all the real work in the background.
  70. \ This way we can keep executing during window drags and menu selections.
  71.  
  72. \ 4.  Dereferenced pointers may become invalid across a PAUSE.  Be careful.
  73.  
  74. : (PAUSE)
  75.     savingDic?  ?EXIT        \ If called during a dic save, mustn't process
  76.                             \  events since modules are purged
  77.     sleepticks  0 -> sleepticks
  78.     getMask: fEvent  $ FFC7 setMask: fEvent        \ all except key events
  79.     next: fEvent  \ IF  2drop  THEN    \ 30Apr94 DBH next: no longer returns stack items
  80.     setMask: fEvent   -> sleepticks  ;
  81.  
  82.  
  83. \ CL3 is the next cleanup word - it cleans up all object stuff on abort,
  84. \ as well as whatever we were doing before (see CL2 in file Files, and CL1
  85. \ in file Class).
  86.  
  87. : CL3
  88.     key!  word0 call hiliteMenu   arrowcurs   unmod
  89.     cl2  ;
  90.  
  91.  
  92. : (SF)
  93.     alive: fWind IF  setContRect: fWind  set: fWind  select: fWind  THEN
  94.     initfont  ;
  95.  
  96. ' (pause)    -> pause
  97. ' sysinit    -> objinit
  98. ' (sf)        -> setFwind
  99. ' cl3        -> abortvec
  100.